#ifndef __RULE_MEASURE_WIDGET_INCLUDE__
#define __RULE_MEASURE_WIDGET_INCLUDE__

#include <QtCore/QObject>
#include <QtWidgets/QWidget>
#include "../UserRegionUtil.h"

class MainMap;

class RuleMeasureTool :public QObject {
    Q_OBJECT
public:
    RuleMeasureTool(QWidget* parent = NULL);
    virtual ~RuleMeasureTool();

public:
    void onMouseMoveEvent(QMouseEvent *event, QPointF geoPos);
    void onMousePressEvent(QMouseEvent *event, QPointF geoPos);
    void onMouseReleaseEvent(QMouseEvent *event, QPointF geoPos);

    void drawMeasure_Line(QPainter& painter, MainMap* mapInstance);
private:
    void onNewPosition(QPointF geoPos);

    void calcMeasure_Line();

    double LengthConvert(double m, int unit);

    QString double2String(double value, int dotN = 2);

public slots:
    void clearStatus();

private:
    userMouseState_t mouseState;
    MainMap* mapSrcWidget;

    QPolygonF measurePos;
    QPointF movePos;
    double Line_Measure_R_Cache;
    double Line_Measure_A_Cache;
};

#endif